#include "ProduceScreen.h"
#include "BaseGame.h"
#include "AudioManager.h"

ProduceScreen::ProduceScreen(hgeFont* font,GameData* gameData) :BaseScreen(font, gameData)
{


	HTEXTURE tex = g_pHge->Texture_Load("Content/up.png");
	HTEXTURE tex2 = g_pHge->Texture_Load("Content/down.png");
	HTEXTURE tex3 = g_pHge->Texture_Load("Content/ProduceScreen.png");
	m_sprite = new hgeSprite(tex3, 0,0,g_pHge->Texture_GetWidth(tex3), g_pHge->Texture_GetHeight(tex3));
	buttU =		new hgeGUIButton(1, 550,520,16,16,tex,0,0);
	buttD =		new hgeGUIButton(2, 550,540,16,16,tex2,0,0);
	//submit =	new hgeGUIButton(3, 250,290,128,32,tex3,0,0);

	hGui = new hgeGUI();
	hGui->Enter();
	hGui->AddCtrl(buttU);
	hGui->AddCtrl(buttD);
	//hGui->AddCtrl(submit);

	guiId = preChoice = 0;
}


ProduceScreen::~ProduceScreen(void)
{
}

void ProduceScreen::Render()
{
	m_sprite->Render(143,0);
	pFont->SetColor( ARGB(255,255,255,255));
	pFont->printf(300,320,HGETEXT_LEFT, "Produce");
	pFont->SetScale(0.5f);
	pFont->printf(160,520,HGETEXT_LEFT, "Helpers working %i", pGameData->HelpersWorking);
	pFont->printf(160,540,HGETEXT_LEFT, "Helpers available for producing %i", pGameData->HelpersAvailable );
	
	pFont->printf(570,520,HGETEXT_LEFT, "Assign worker");
	pFont->printf(570,540,HGETEXT_LEFT, "Remove worker");
	pFont->SetScale(1);

	//pFont->printf(300, 200, HGETEXT_LEFT, "Assign helpers to workers: %i", preChoice);
	hGui->Render();

}

void ProduceScreen::Update(float fDeltaTime)
{

	guiId = hGui->Update(fDeltaTime);

	if(guiId != 0)
	{
		switch (guiId)
		{
		case 1:
			if(pGameData->HelpersAvailable > 0)
			{
				pGameData->HelpersAvailable--;
				pGameData->HelpersWorking++;
				g_pAudioManager->PlayEffect("huh1");

			}
			break;
		case 2:
			if(pGameData->HelpersWorking > 0)
			{
				pGameData->HelpersAvailable++;
				pGameData->HelpersWorking--;
				g_pAudioManager->PlayEffect("huh2");

			}
			break;
		/*case 3:
			if(preChoice > 0)
			{
				pGameData->HelpersWorking += preChoice;
				preChoice = 0;
			}
			break;*/
		default:
			break;
		}
		
	}
}